package com.qf.controller;

import com.qf.entity.Employee;
import com.qf.service.UserService;
import com.qf.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * @Author cuicui
 * @Description
 * @Date 2025-8-9
 */
@RestController
public class EmployeeController {
    @Autowired
    private UserService userService;

    // 查询全部列表
    @GetMapping("/employee/findAllEmployee")
    public R findAllEmployee() {
        List<Employee> list = userService.findAllEmployee();
        return R.success(list);
    }


    // 根据条件进行查询  ename和job
    @GetMapping("/employee/findEmployeeByCondition")
    public R findEmployeeByCondition(String ename, String job) {
        List<Employee> list = userService.findEmployeeByCondition(ename, job);
        return R.success(list);
    }

    // 增加数据
    @GetMapping("/employee/addEmployee")
    public R addEmployee(Employee employee) {
        int i = userService.addEmployee(employee);
        return R.success(i);
    }

    // 删除数据
    @GetMapping("/employee/deleteEmployee")
    public R deleteEmployee(int empno){
        int i = userService.deleteEmployee(empno);
        return R.success(i);
    }
// 修改数据
    @GetMapping("/employee/updateEmployee")
    public R updateEmployee(Employee employee){
        int i = userService.updateEmployee(employee);
        return R.success(i);
    }
}
